<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <script>if (window !== top) top.location.replace(location.href);</script>
        <meta charset="utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link th:href="@{/assets/expand/images/favicon.ico}" rel="icon">
        <title>登录</title>
        <link rel="stylesheet" th:href="@{/assets/common/libs/layui/css/layui.css}"/>
        <link rel="stylesheet" th:href="@{/assets/common/module/admin.css}"/>
        <link rel="stylesheet" th:href="@{/assets/common/css/login2.css}"/>
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
        <style type="text/css" th:inline="css">
            body {
                background-image: url("[[${bg}]]");
                background-repeat: no-repeat;
                background-size: cover;
                min-height: 100vh;
            }
        </style>
    </head>
    <body>
        <div class="login-wrapper">
            <form class="layui-form">
                <h2>用户登录</h2>
                <th:block th:if="${tenant}">
                    <div class="layui-form-item layui-input-icon-group">
                        <i class="layui-icon layui-icon-username"></i>
                        <select name="tenantCode" id="tenantCode">
                            <option value="">杭州淼龙信息科技有限公司</option>
                            <option th:each="item:${tenantList}" th:value="${item.getCode()}">[[${item.getName()}]]</option>
                        </select>
                    </div>
                </th:block>
                <div class="layui-form-item layui-input-icon-group">
                    <i class="layui-icon layui-icon-username"></i>
                    <input class="layui-input" id="username" name="username" placeholder="请输入登录账号" value="admin"
                           autocomplete="off" lay-verType="tips" lay-verify="required" required/>
                </div>
                <div class="layui-form-item layui-input-icon-group">
                    <i class="layui-icon layui-icon-password"></i>
                    <input class="layui-input" id="password" name="password" placeholder="请输入登录密码" value="111111"
                           type="password" lay-verType="tips" lay-verify="required" required/>
                </div>
                <!--@if(constants.getKaptchaOpen()){
                <div class="layui-form-item layui-input-icon-group login-captcha-group">
                    <i class="layui-icon layui-icon-auz"></i>
                    <input class="layui-input" id="kaptcha" placeholder="请输入验证码" autocomplete="off" lay-verType="tips"
                           lay-verify="required" required/>
                    <img class="login-captcha" src="${ctxPath}/kaptcha" alt=""/>
                </div>
                @}-->
                <!--        <div class="layui-form-item">-->
                <!--            <input type="checkbox" name="remember" title="记住密码" lay-skin="primary" checked>-->
                <!--            <a href="javascript:;" class="layui-link pull-right">注册账号</a>-->
                <!--        </div>-->
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" id="submit" lay-submit lay-filter="login">登录</button>
                </div>
                <!--<div class="layui-form-item login-oauth-group text-center">
                    <a th:href="@{/oauth/render/qq}"><i class="layui-icon layui-icon-login-qq"
                                                        style="color:#3492ed;"></i></a>&emsp;
                    <a th:href="@{/oauth/render/gitee}">
                        <img class="layui-icon" style="height: 28px;width: 28px; margin-top: -12px !important;"
                             th:src="@{/assets/expand/images/git.png}"/>
                    </a>
                </div>-->
            </form>
        </div>
        <div class="login-copyright">copyright © 2020 stylefeng.cn all rights reserved.</div>

        <!--加入contextPath属性和session超时的配置-->
        <script type="text/javascript">
            var Kong = {
                ctxPath: "[(${ctxPath})]",
                version: "[(${version})]"
            };
        </script>

        <!-- js部分 -->
        <script type="text/javascript" th:src="@{/assets/common/libs/layui/layui.js}"></script>
        <script type="text/javascript" th:src="@{/assets/common/js/common.js}"></script>
        <script>
            layui.use(['layer', 'form', 'ax', 'index', 'notice'], function () {
                var $ = layui.jquery,
                    layer = layui.layer,
                    form = layui.form,
                    $ax = layui.ax,
                    index = layui.index,
                    notice = layui.notice;

                var errorMsg = "[[${tips}]]";
                if (errorMsg) {
                    layer.msg(errorMsg, {icon: 5, anim: 6});
                }

                form.on('submit(login)', function (obj) {
                    var ajax = new $ax(Kong.ctxPath + "/login", function (data) {
                        Kong.success("登录成功!");
                        index.clearTabCache();
                        window.location.href = Kong.ctxPath + "/";
                    }, function (data) {
                        Kong.error("用户名或密码错误");
                    });
                    ajax.setMethod("post");
                    ajax.setData(obj.field)
                    ajax.send();
                    return false;
                })

            })


        </script>


    </body>
</html>